<?php

/**
 *      [Discuz!] (C)2001-2099 Comsenz Inc.
 *      This is NOT a freeware, use is subject to license terms
 *
 *      $Id: table_forum_announcement.php 27829 2012-02-15 07:34:43Z chenmengshu $
 */

if(!defined('IN_DISCUZ')) {
	exit('Access Denied');
}

class table_master_works extends discuz_table
{
	public function __construct() {

		$this->_table = 'master_works';
		$this->_pk    = 'id';

		parent::__construct();
	}

	public function fetch_all( $where = '', $limit = '', $order = '' ){
		$where		= empty( $where ) ? '' : " WHERE {$where}";
		$limit		= empty( $limit ) ? '' : " LIMIT {$limit}";
		$order		= empty( $order ) ? '' : " ORDER BY {$order}";
		$sql		= "SELECT SQL_CALC_FOUND_ROWS `a`.*, `b`.`name`, `b`.`uid` 
						FROM pre_{$this->_table} AS `a` 
						LEFT JOIN `pre_master_main` AS `b` ON `a`.`mid` = `b`.`id`
						{$where} {$order} {$limit}";
		$list		= DB::fetch_all( $sql );
		$num		= DB::fetch_first( "SELECT FOUND_ROWS() AS `num` " );

		return array( 'list' => $list, 'num' => $num['num'] );
	}
}

?>